//
//  MyGradeDJTQSectionHeaderView.m
//  我的等级
//
//  Created by 田涛 on 2017/9/29.
//  Copyright © 2017年 Lemon. All rights reserved.
//

#import "MyGradeDJTQSectionHeaderView.h"
#import "GlobalHeader.h"

@interface MyGradeDJTQSectionHeaderView ()
/** 顶部横线*/
@property (nonatomic, strong)  UILabel *topLine;
/** 底部横线*/
@property (nonatomic, strong)  UILabel *bottomLine;
/** 标题*/
@property (nonatomic, strong)  UILabel *titleLbl;
/** 等级介绍*/
@property (nonatomic, strong)  UILabel *gradeLbl;
@end

@implementation MyGradeDJTQSectionHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setup];
        [self layout];
    }
    return self;
}


/**
 *  初始化
 */
- (void)setup {
    [self addSubview:self.topLine];
    [self addSubview:self.bottomLine];
    [self addSubview:self.titleLbl];
    [self addSubview:self.gradeLbl];
}

- (void)setModel:(MyGradeDJTQModel *)model {
    _model = model;
    _gradeLbl.text = model.gradeDescription;
}

/**
 *  布局
 */
- (void)layout {
    self.topLine.sd_layout
    .topSpaceToView(self, 0)
    .leftSpaceToView(self, 0)
    .rightSpaceToView(self, 0)
    .heightIs(HeightScale_IOS7(3));
    
    self.bottomLine.sd_layout
    .bottomSpaceToView(self, 0)
    .leftSpaceToView(self, 0)
    .rightSpaceToView(self, 0)
    .heightIs(HeightScale_IOS7(3));
    
    self.titleLbl.sd_layout
    .topSpaceToView(self.topLine, 0)
    .leftSpaceToView(self, WidthScale_IOS7(15))
    .bottomSpaceToView(self.bottomLine, 0);
    [self.titleLbl setSingleLineAutoResizeWithMaxWidth:SCREEN_WIDTH /2];
    
    self.gradeLbl.sd_layout
    .topSpaceToView(self.topLine, 0)
    .rightSpaceToView(self, WidthScale_IOS7(25))
    .bottomSpaceToView(self.bottomLine, 0);
    [self.gradeLbl setSingleLineAutoResizeWithMaxWidth:SCREEN_WIDTH /2];
}


#pragma mark - 懒加载
- (UILabel *)topLine {
    if (!_topLine) {
        _topLine = [[UILabel alloc] init];
        _topLine.backgroundColor = RGB(236, 236, 236);
    }
    return _topLine;
}

- (UILabel *)bottomLine {
    if (!_bottomLine) {
        _bottomLine = [[UILabel alloc] init];
        _bottomLine.backgroundColor = RGB(236, 236, 236);
    }
    return _bottomLine;
}

- (UILabel *)titleLbl {
    if (!_titleLbl) {
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.text = @"等级特权";
        _titleLbl.font = [UIFont systemFontOfSize:WidthScale_IOS7(16)];
    }
    return _titleLbl;
}

- (UILabel *)gradeLbl {
    if (!_gradeLbl) {
        _gradeLbl = [[UILabel alloc] init];
        _gradeLbl.font = [UIFont systemFontOfSize:WidthScale_IOS7(14)];
        _gradeLbl.textColor = [UIColor lightGrayColor];
    }
    return _gradeLbl;
}

@end
